<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<title>新建拉群</title>
	<link rel="stylesheet" href="/layui/css/layui.css">
	<link rel="stylesheet" href="/hyqcss/public.css">
  	{$h->import('static/css/StoreCodeSetting.css')}
	<style type="text/css">
		body{
			background: #e9e9e9;
			width: 100%;
		}
		/*公共头部带搜索*/
		.public_container{
			margin: 20px; 
			background: #fff;
		} 
		.public_title_container{
			height: 54px;
			padding: 0 20px;
			font-size: 14px;
			display: flex;
			align-items: center;
			background: #f9f9f9;
			border-bottom: 1px solid #f0f0f0;
			justify-content: space-between;
		}
		.public_title_container a{
			fill: #999;
		}
		/*公共表单部分*/
		.public_form_container{
			padding: 20px 20px 40px 20px;
		}
		.public_form_content{
			padding: 24px 40px 24px 0;
			background: #fff;
			border: 1px solid #e9e9e9;
			margin-bottom: 8px;
		}
		.process-item{
			padding: 10px 16px;
		    text-align: center;
		    background: #eff8ff;
		    border-radius: 4px;
		    border: 2px solid #8ac7ff;
		    font-size: 13px;
		    color: rgba(0,0,0,.85);
		    /*width: 120px;*/
		}
		.process-example {
		    margin-top: 20px;
		    margin-bottom: 16px;
		    display: -webkit-box;
		    display: flex;
		    -webkit-box-align: center;
		    align-items: center;
		}
		.hs{
			margin-left: 20px;
		}
		.notify-info {
			margin-left: 20px;
		    width: 650px;
		    margin-top: 16px;
		    margin-bottom: 10px;
		    display: inline-block;
		    padding: 12px 5px;
		    font-size: 13px;
		    color: #bb5223;
		    background: #fff7f0;
		    border-radius: 3px;
		}
		.public_form_List{
			margin-bottom: 10px;
		}
		.public_form_List:last-child{
			margin-bottom: 0px;
		}
		/*新加的二维码*/
		.uploadQrcode_container{
			display: flex;
			align-items: center;
		}
		.uploadQrcode_container button{
			margin-left: 15px;
		}
		.uploadQrcode_container span{
			color: #999;
			font-size: 13px;
		}
		.uploadQrcode_content{
			position: relative;
			width: 150px;
			height: 150px;
			overflow: hidden;
		}
		.qrcodeImg_h{
			width: 150px;
			height: 150px;
		}
		.qrcodeHead_h{
			width: 35px;
			height: 35px;
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translate(-50%, -50%);
		}
		.service-card {
		  padding: 0 7px;
		  color: rgba(0,0,0,.65);
		  line-height: 28px;
		  font-size: 13px;
		  display: inline-block;
		  margin: 0 8px 0 5px;
		  -webkit-box-sizing: border-box;
		  box-sizing: border-box;
		  white-space: nowrap;
		  background: #fafafa;
		  border: 1px solid #e9e9e9;
		  border-radius: 4px;
		  position: relative;
		}
		.service-card i {
		  font-size: 14px;
		  display: inline-block;
		  color: #7da3d1;
		  margin-right: 2px;
		}
		.service-card .close {
		  position: absolute;
		  top: -13px;
		  right: -8px;
		  opacity: .6;
		  cursor: pointer;
		}
		.service-card .close:hover {
		  opacity: 1;
		}
		.public_formTitle_container lable{
			font-size: 13px;
			font-weight: bold;
		}
		.content {
		    display: -webkit-box;
		    display: flex;
		    -webkit-box-orient: vertical;
		    -webkit-box-direction: normal;
		    flex-direction: column;
		    -webkit-box-align: start;
		    align-items: flex-start;
		    -webkit-box-pack: justify;
		    justify-content: space-between;
		    margin-bottom: 20px;
		}
		 .qw-code-item {
		    width: 500px;
		    background: #fbfbfb;
		    border-radius: 2px;
		    border: 1px solid #eee;
		    position: relative;
		}
		.qw-code {
		    padding: 16px;
		    border-bottom: 1px solid #eee;
		    height: 130px;
		}
		.number-limit {
		    height: 56px;
		    padding: 0 16px;
		    color: #666;
		    display: -webkit-box;
		    display: flex;
		    -webkit-box-align: center;
		    align-items: center;
		    -webkit-box-pack: justify;
		}
		input::-webkit-outer-spin-button,
    	input::-webkit-inner-spin-button {
    		-webkit-appearance: none !important;
        	margin: 0;
    	}
    	.label {
		    left: 158px;
		    width: auto;
		    position: absolute;
		    height: 20px;
		    padding: 0 8px;
		    display: -webkit-box;
		    display: flex;
		    -webkit-box-pack: center;
		    justify-content: center;
		    -webkit-box-align: center;
		    align-items: center;
		    font-size: 12px;
		    color: rgba(0,0,0,.65);
		    background: #f2f2f2;
		    border-radius: 2px;
		    border: 1px solid #d1d1d1;
		}
		.success {
		    background: #e8fcdc;
		    border: 1px solid #a1ec9f;
		}
	</style>
</head>
<body>
<form class="layui-form" id="form1">
	<!-- 顶部提示框 开始 -->
	<div class="public_tipSetting_contaienr">
		<div class="public_tipSetting_content">
			<p>客户入群需要扫描两个二维码，将先扫企业后台活码，再扫企业微信活码，入群过程不会添加企业员工，不会成为企业客户哦～ &nbsp;</p>
			<a href="https://shimo.im/docs/1lq7MKlxWLuQxAew/" target="_blank">去企业微信创建</a>
			<svg t="1599462804099" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8813" width="15" height="15"><path d="M512 102.4a409.6 409.6 0 1 0 409.6 409.6 409.6 409.6 0 0 0-409.6-409.6z m181.248 518.144a51.2 51.2 0 0 1-72.704 72.704L512 584.192l-108.544 109.056a51.2 51.2 0 0 1-72.704-72.704L439.808 512 330.752 403.456a51.2 51.2 0 0 1 72.704-72.704L512 439.808l108.544-109.056a51.2 51.2 0 0 1 72.704 72.704L584.192 512z" fill="" p-id="8814"></path></svg>
		</div>
	</div>
	<div class="public_container">
		<!-- /*公共头部带搜索*/ -->
		<div class="public_content">
			<div class="public_title_container">
				<p>新建拉群</p>
				<a href="javascript:history.back(-1)">
					<svg t="1599462684269" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8055" width="20" height="20"><path d="M501.2992 273.408l1.024-156.16L184.65792 379.904l314.29632 266.1376 0.95232-149.2992c313.86624 42.5984 178.29888 231.3216-0.5632 410.2144 619.5712-404.3776 251.01312-590.6432 1.95584-633.5488z" p-id="8056"></path></svg>
				</a>
			</div>
		</div>
		<!-- /*公共头部带搜索*/ end -->
		<!-- 公共表单部分 -->
		<div class="public_form_container">
			<div class="public_form_content">
				<h3 class="hs">客户扫码入群流程</h3><hr class="hs">
				<div style="margin-top: 12px;margin-left: 20px;">
					<h3>无限拉群</h3><br>
					<span style="font-size: 14px; color: #000000A6; margin-right: 20px">
						企业无需创建群聊即可开始拉群任务，客户扫码不用添加企业成员即可入群，简化客户入群流程，增加客户入群率，方便企业管理。
					</span> 
					<a href="https://shimo.im/docs/1lq7MKlxWLuQxAew/" target="_blank" style="color: #1890ff;">了解更多如何使用？</a>
				</div>
				<div class="process-example">
					<div class="process-item" style="margin-left: 20px;"> 用户扫企业后台活码码 </div>
					<img class="process-arrow" src="https://assets.weibanzhushou.com/web/we-work-webapp/group-infinite_process-arrow.98acdffa653b.png" alt="">
					<div class="process-item"> 扫描企微活码 </div>
					<img class="process-arrow" src="https://assets.weibanzhushou.com/web/we-work-webapp/group-infinite_process-arrow.98acdffa653b.png" alt="">
					<div class="process-item"> 加入群聊 </div>
				</div>
			</div>

			<div class="public_form_content">
				<h3 class="hs">企业活码设置</h3><hr class="hs">
				<div class="notify-info">
					<svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><use xlink:href="#tixing"><svg id="tixing" viewBox="0 0 1024 1024"><path d="M847.596308 710.813538c-18.274462-34.185846-40.96-166.596923-40.96-288.768 0-122.092308-39.699692-220.553846-133.12-266.555076-32.137846-15.753846-91.293538-48.521846-98.934154-85.07077C567.099077 33.870769 556.307692 0 512.669538 0c-0.315077 0-0.551385 1.024-0.787692 1.181538C511.409231 1.102769 511.251692 0 510.936615 0c-43.638154 0-54.587077 33.713231-61.991384 70.340923-7.561846 36.627692-66.796308 69.316923-98.934154 85.149539-93.341538 46.001231-133.12 144.462769-133.12 266.555076 0 122.249846-22.685538 254.660923-40.96 288.768-18.116923 34.107077-57.974154 66.638769-57.974154 111.064616v37.100308s222.916923-37.021538 392.979692-37.021539c169.905231 0 394.712615 37.021538 394.712616 37.021539v-37.021539c-0.236308-44.504615-39.936-77.036308-58.131693-111.064615z m-336.738462 155.411693c-39.542154 0-81.841231 2.126769-123.510154 5.198769 12.051692 64.039385 61.833846 113.191385 124.455385 113.191385 62.779077 0 112.324923-48.994462 124.455385-113.112616a1767.817846 1767.817846 0 0 0-125.400616-5.277538z"></path></svg></use></svg>入群人数统计规则：扫企业后台活码码即认为客户入群，扫码人数会与实际扫企业微信活码入群人数有偏差 
				</div>
				<div class="public_form_List" style="margin-bottom: 50px;">
					<div class="public_formTitle_container">
						<lable class="layui-form-label"><span style="color: red;">*</span> 群码名称：</lable>
					</div>
					<div class="public_formOther_container">
						<div class="layui-input-block">
							<input type="text"  value="{$infinite->name}" name="name" required  lay-verify="required" placeholder="名称不会展示给用户，用于企业记录渠道名称或使用场景,最多支持12个字符" autocomplete="off" class="layui-input" maxlength="12" style="width: 535px;">
						</div>
					</div>
				</div>
				<h3 class="hs">企微活码设置</h3><hr class="hs">
				<div class="public_form_List">
					<div class="public_formTitle_container">
						<lable class="layui-form-label">群名称设置:</lable>
					</div>
					<div class="public_formOther_container">
						<div class="layui-input-block">
					      	<input type="checkbox" name="group_name_set" lay-skin="switch" lay-filter="switchTest" {if $infinite->group_name_set == 1}checked{/if}>
					      	<input type="text" value="{$infinite->group_name}" name="group_name" required placeholder="请输入群名称，限制长度在30位" autocomplete="off" class="layui-input" maxlength="30"  {if $infinite->group_name_set != 1}readonly="readonly"{/if}  id="group_name" style="width: 535px;"/>
					    </div>
					</div>
				</div>
				<div class="public_form_List">
					<div class="public_formTitle_container">
						<lable class="layui-form-label">入群引导语:</lable>
					</div>
					<div class="public_formOther_container">
						<div class="layui-input-block">
					      	<input type="checkbox" name="group_guide_set" lay-skin="switch" lay-filter="switchTests" {if $infinite->group_guide_set == 1}checked{/if}>
					      	<input type="text" value="{$infinite->group_guide}" name="group_guide" required placeholder="请输入群引导语，限制长度在30位" autocomplete="off" class="layui-input" maxlength="30" {if $infinite->group_guide_set != 1}readonly="readonly"{/if} id="group_guide" style="width: 535px;"/>
					    </div>
					</div>
				</div>
				<div class="public_form_List">
					<div class="public_formTitle_container">
						<lable class="layui-form-label">上传头像:</lable>
					</div>
					<div class="public_formOther_container">
						<div class="layui-input-block">
							<input type="hidden" name="imgs" id="filess" value="{$infinite->group_code}">
					      	<img style="width: 100px;height: 100px;background: url('https://qiye.sophp.cn/infinite/touxiang.png')" data-target="files" onclick="select_imgs(this)" id="fil" {if $infinite->group_code} src="{$infinite->group_code}" {/if}>
					    </div>
					</div>
				</div>
				<div class="PopSetting_mainLeft_container" style="position: absolute;left: 720px;top: 700px;">
					<img class="PopSetting_mainPhone_bg_container" src="http://weidogstest.oss-cn-beijing.aliyuncs.com/755bb61d09d97d73be9e0bce2713151e.png">
					<h5 class="PopSetting_mainPhone_title">加入群聊</h5>
					<div class="PopSetting_mainPhone_container">
						<!-- 切换 默认样式 -->
						<div class="PopSetting_mainPhone_qrcode_container" style="margin-top: 60px; height: 440px">
							<div class="PopSetting_mainPhone_qrcode_content">
								<div class="PopSetting_mainPhone_qrcodeHeader_container">
									<div class="PopSetting_mainPhone_qrcodeHeader_content">
										<img src="{$infinite->group_code}" id="demo2s" {if !$infinite->group_code}style="display: none;" {/if}>
									</div>
									<div class="PopSetting_mainPhone_qrcodeHeaderInfo_content">
										<b></b>
										<span></span>
									</div>
								</div>
								<img class="PopSetting_mainPhone_qrcode" src="http://weidogstest.oss-cn-beijing.aliyuncs.com/4d2d2764c19d0b6962fe41eaec2b7c07.png">
								<div class="ScanQrcodeText_container">
									<svg t="1622801276149" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2135" width="12" height="12"><path d="M898 398c-17.48-42.18-55.58-67.37-101.93-67.37-21.39 0-41 5.57-58 16.27a110.86 110.86 0 0 0-169.64-21.29 110.85 110.85 0 0 0-117-22.33V125.91a100.93 100.93 0 0 0-201.86 0v312.41A111 111 0 0 0 72.71 569.69C82.2 588 212.85 840.31 260 925a108.58 108.58 0 0 0 8.64 15c0.53 0.8 1.07 1.57 1.65 2.32a108.7 108.7 0 0 0 88 44.91H698.8c52.06 0 85.21-9.59 107.48-31.09 22.07-21.31 26.66-48.08 30.7-71.69l68.28-421.56A119.66 119.66 0 0 0 898 398z m-61.87 53.76L768 872.82c-3 17.18-5.12 28-10.3 33-4.43 4.28-18 11.45-58.86 11.45H358.31a38.47 38.47 0 0 1-31.13-15.72c-1.39-2.42-2.91-5.11-4.56-8-0.08-0.2-0.18-0.39-0.26-0.59a35.06 35.06 0 0 0-4.58-8.13c-50-90.62-181.8-345.13-183.23-347.9l-0.78-1.42a41 41 0 0 1 15-56 41 41 0 0 1 55.91 14.83c2.56 4.59 31.8 56.79 45.41 80.7a35 35 0 0 0 69.53-5.69V125.91a30.93 30.93 0 1 1 61.86 0v377.51a35 35 0 0 0 70 0v-97a41 41 0 0 1 82 0v87a35 35 0 0 0 70 0v-87a41 41 0 1 1 82 0v87a35 35 0 0 0 70 0v-58.2a56.12 56.12 0 0 1 10.68-20.81c7.81-9.43 17.32-13.83 29.94-13.83 22.52 0 32.69 13.14 37.26 24.16a49.68 49.68 0 0 1 2.81 26.97z" fill="#B5BEC8" p-id="2136"></path></svg>
									<p class="ScanQrcodeText"></p>
								</div>
								
								<div class="PopSetting_mainPhone_qrcodeAddress_container" {if $set->is_address != 1} style="display:none;" {/if}>
									<svg t="1622797340460" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2727" width="15" height="15"><path d="M512 32c-191.6 0-347 159.6-347 356.4 0 188.5 185.2 437.9 328.3 595.3 10.1 11.1 27.3 11.1 37.4 0C673.8 826.3 859 576.9 859 388.4 859 191.6 703.6 32 512 32z m0 467.4c-76.7 0-138.8-62.1-138.8-138.8S435.3 221.8 512 221.8s138.8 62.1 138.8 138.8S588.7 499.4 512 499.4z" p-id="2728" fill="#a1d2ff"></path></svg>
									<span></span>
								</div>
							</div>
							<h5></h5>
						</div>
					</div>
				</div>
				<div style="margin-bottom: 16px; margin-top: 0; color: rgba(0, 0, 0, 0.44); padding: 8px 16px; background: #EFFAFF;" class="notify-info">
					<svg style="color: #0099FF;" width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><use xlink:href="#tixing"></use></svg> 请上传在企业微信后台创建的活码 
					<a style="margin-left: 8px;margin-right: 8px;color: #1890ff;" target="_blank" href="https://work.weixin.qq.com/wework_admin/frame#chatGroup/create/qrCode">去创建</a> 
					<a target="_blank" href="https://shimo.im/docs/1lq7MKlxWLuQxAew/" style="color: #1890ff;">查看如何创建</a>
				</div>
				<div class="public_form_List part-time-list">
					{if count($data)}
					{loop $data as $key=>$value}
						<div class="part-time-item">
							<div class="public_formTitle_container">
								<lable class="layui-form-label part-time-item-index">企微活码{$key+1}:</lable>
							</div>
							<div class="public_formOther_container">
								<div class="layui-input-block">
							      	<div class="content">
							      		<div class="qw-code-item">
							      			<div class="qw-code">
							      				<input type="hidden" class="addPeople" name="imgs{$key+1}" id="data_part_time_otype_img{$key+1}" value="{$value['qr_code']}">
							      				<input type="hidden" name="id{$key+1}" id="id{$key+1}" value="{$value['id']}">
					                            {if $value["status"] == 1}
					                            	<div class="label success"> 拉人中 </div>
					                            	<img class="addPeople" style="width: 100px;height: 100px;background: url('https://qiye.sophp.cn/infinite/ma.png')" data-target="part_time_otype_img{$key+1}" data-id="1" onclick="select_imgs(this)" id="part_time_otype_img{$key+1}" src="{$value['qr_code']}">
									      			<div class="number-limit">
									      				群活码人数上限: <input class="addPeople" type="number" name="size{$key+1}" id="size{$key+1}" value="{$value['size']}" style="width: 10%;height: 30px;" class="layui-input" readonly="readonly" onkeydown="handleFocus(this)">
									      			</div>
										      	{else if $value["status"] == 2}
										      		<div class="label"> 已满员 </div>
										      		<img class="addPeople" style="width: 100px;height: 100px;background: url('https://qiye.sophp.cn/infinite/ma.png')" data-target="part_time_otype_img{$key+1}" data-id="1" onclick="select_imgs(this)" id="part_time_otype_img{$key+1}" src="{$value['qr_code']}">
									      			<div class="number-limit">
									      				群活码人数上限: <input class="addPeople" type="number" name="size{$key+1}" id="size{$key+1}" value="{$value['size']}" style="width: 10%;height: 30px;" class="layui-input" readonly="readonly" onkeydown="handleFocus(this)">
									      			</div>
									      		{else}
					                            	<div class="label"> 未开启 </div>
					                            	<img class="addPeople" style="width: 100px;height: 100px;background: url('https://qiye.sophp.cn/infinite/ma.png')" data-target="part_time_otype_img{$key+1}" data-id="0" onclick="select_imgs(this)" id="part_time_otype_img{$key+1}" src="{$value['qr_code']}">
									      			<div class="number-limit">
									      				群活码人数上限: <input class="addPeople" type="number" name="size{$key+1}" id="size{$key+1}" value="{$value['size']}" style="width: 10%;height: 30px;" class="layui-input" onkeydown="handleFocus(this)">
									      			</div>
										      	{/if}
							      			</div>
							      		</div>
							      		<!-- 删除 -->
									    <button type="button" class="addPeople layui-btn layui-btn-sm layui-btn-primary part-time-item-del" style="position: absolute;left: 510px;top: 135px;" {if $value["status"] == 1} data-id="1" {else if $value["status"] == 2} data-id="1" {else}  data-id="0" {/if}>
												<i class="layui-icon">&#xe640;</i>
										</button>
							      	</div>
							    </div>
							</div>
						</div>
					{/loop}
					{else}
					<div class="part-time-item">
						<div class="public_formTitle_container">
							<lable class="layui-form-label part-time-item-index">企微活码1:</lable>
						</div>
						<div class="public_formOther_container">
							<div class="layui-input-block">
						      	<div class="content">
						      		<div class="qw-code-item">
						      			<div class="qw-code">
						      				<input type="hidden" class="addPeople" name="imgs1" id="data_part_time_otype_img1">
									      	<img class="addPeople" style="width: 100px;height: 100px;background: url('https://qiye.sophp.cn/infinite/ma.png')" data-target="part_time_otype_img1" onclick="select_imgs(this)" id="part_time_otype_img1">
						      			</div>
						      			<div class="number-limit">
						      				群活码人数上限: <input class="addPeople" type="number" name="size1" id="size1" value="1000" style="width: 10%;height: 30px;" class="layui-input" onkeydown="handleFocus(this)">
						      			</div>
						      		</div>
						      		<!-- 删除 -->
								    <button type="button" class="layui-btn layui-btn-sm layui-btn-primary part-time-item-del" style="position: absolute;left: 510px;top: 190px;">
											<i class="layui-icon">&#xe640;</i>
									</button>
						      	</div>
						    </div>
						</div>
					</div>
					{/if}
				</div>
				<button type="button" class="layui-btn layui-btn-primary part-time-btn-add"style="color: #1E9FFF;margin-left: 92px;border: 0;background: transparent;"><i class="layui-icon">&#xe608;</i> 添加企微活码
				</button>
				<input type="hidden" id="partTimeCount" name="counts" value="{count($data)?:1;}">
			</div>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<a class="layui-btn" lay-submit lay-filter="formDemo">保存</a>
				</div>
			</div>
		</div>
	</div>
</form>
<script src="/cdn/jquery.js"></script>
<script src="/layui/layui.js"></script>
<script src="/layui/layui.all.js"></script>
<script src="/js/ajax.js"></script>
<script type="text/javascript">
	window.onload = function(){ 
		$('.PopSetting_mainPhone_qrcodeHeaderInfo_content b').text($('#group_name').val());
		$('.PopSetting_mainPhone_qrcodeHeaderInfo_content span').text($('#group_guide').val());
　　}
	layui.use('form', function(){
	  	var form = layui.form;
	  	form.on('switch(switchTest)', function(data){
	   		if(this.checked){
	   			$('#group_name').attr("readonly",false);
	   			$('#group_name').focus();
	   			$('#group_name').attr("lay-verify","required");
	   		}else{
	   			$('#group_name').attr("readonly","readonly");
	   			$('#group_name').removeAttr("lay-verify","required");
	   		}
	  	});
	  	form.on('switch(switchTests)', function(data){
	   		if(this.checked){
	   			$('#group_guide').attr("readonly",false);
	   			$('#group_guide').focus();
	   			$('#group_guide').attr("lay-verify","required");
	   		}else{
	   			$('#group_guide').attr("readonly","readonly");
	   			$('#group_guide').removeAttr("lay-verify","required");
	   		}
	  	});
	  	//监听提交
  		form.on('submit(formDemo)', function(data){
			var formData = $('#form1').serialize();	
			myAjaxPost(false, true, '', formData, function (resp) {
				tusi(resp.msg);
				if(resp.status == "success"){
					setTimeout(function(){
						location.href = 'index.html';
					},1000);
				}
			});
	  	});
	});
	// 开启状态输入框改变事件
	$('#group_guide').bind('keyup', function(event) {
		$('.PopSetting_mainPhone_qrcodeHeaderInfo_content span').text($(this).val());
	})
	$('#group_name').bind('keyup', function(event) {
		$('.PopSetting_mainPhone_qrcodeHeaderInfo_content b').text($(this).val());
	})
	//关闭头部
	$('.public_tipSetting_contaienr svg').click(function(){
		$('.public_tipSetting_contaienr').hide();
	})
	//判断输入人数上线
	function handleFocus(th){
		if($(th).val() > 1000){
			$(th).val(1000);
		}
	}
</script>
<script type="text/javascript">
	// 添加时间段
	function addOnePartTime() {
		var $items = $('.part-time-list .part-time-item')
		var length = $items.length
		if (!length) {
			return console.error('至少要有一个 .part-time-item 用作模板')
		}
		var tpl = $items.eq(0).clone(false)
		setPartTimeItemId(tpl, length + 1, true)
		tpl.find('.label').text('未开启')
		tpl.find('.label').removeClass('success')
		$(".part-time-list").append(tpl)
		setCount(length + 1)
	}
	function setPartTimeItemId($item, index, clear) {
		$item.find('.part-time-item-index').text('企微活码' + index + '：')
		var $sImgBtns = $item.find('.addPeople')
		for (var i = 0, l = $sImgBtns.length; i < l; i++) {
			setElemAttr($($sImgBtns[i]), index)
		}
		return $item
	}
	function setElemAttr($elem, index) {
		var id = $elem.attr('id'), name = $elem.attr('name'), _name = $elem.attr('_name'), dataTarget = $elem.attr('data-target'), layKey = $elem.attr('lay-key'), xmSelect = $elem.attr('xm-select');
		var reg = /([0-9]+)/g
		$elem.attr({
			id: id && (id.replace(reg, '') + index),
			name: name && (name.replace(reg, '') + index),
			'data-id': 0, // 上传图片按钮
			'data-target': dataTarget && (dataTarget.replace(reg, '') + index), // 上传图片按钮
			'_name': _name && (_name.replace(reg, '') + index), // 日期多选
			'xm-select': xmSelect && (xmSelect.replace(reg, '') + index), // 日期多选
			'lay-key': layKey ? (String(index) + Date.now()) : layKey, // 时间选择器
			'readonly': false, 
		});
	}
	// 添加时间段按钮
	$('.part-time-btn-add').on('click', addOnePartTime)
	// 删除时间段
	$('.part-time-list').on('click', '.part-time-item-del', function() {
		if($(this).data("id")){
			return false;
		}
		if ($('.part-time-list .part-time-item').length <= 1) {
			tusi('不能再少了')
		} else {
			$(this).parent().parent().parent().parent().remove()
			updateItemsOrder()
		}
	})

	function updateItemsOrder() {
		var $items = $('.part-time-list .part-time-item')
		var l = $items.length
		setCount(l)
		for (var i = 0; i < l; i++) {
			var $theItem = $($items[i])
			setPartTimeItemId($theItem, i + 1, false)
		}
		layui.form.render()
		initTimeSelects()
	}

	function setCount(n) {
		if (n === undefined) {
			n = $('.part-time-list .part-time-item').length
		}
		$('#partTimeCount').val(n)
	}
</script>

<script type="text/javascript">
	layui.use(['element', 'layer', 'upload'], function () {
	  var layer = layui.layer;
	});
	function select_imgs(a){
		if($(a).data("id")){
			return false;
		}
	  var targetId=a.getAttribute('data-target');
	  layer.open({
		title:'图片库',
		type: 2,
		area: ['700px', '450px'],
		fixed: false, //不固定
		maxmin: false,
		content: '/imgLib/lib.html?type=vshop_img&target='+targetId
	  });
	}

	window.uploadImgCallback=function (tgt,url) {
	  if(tgt=='files'){
		var inputEle=$('#filess');
		var prevEle=$('#fil');
		var demo2s=$('#demo2s');
		inputEle.val(url);
		demo2s.show();
		demo2s.attr('src',url);
		prevEle.attr('src',url);
	  }else if(tgt.indexOf('part_time_') > -1){ // 分时段 通用
		var inputEle=$('#' + tgt);
		var prevEle=$('#data_' + tgt);
		prevEle.val(url);
		inputEle.attr('src',url);
	  }
	};
</script>
</body>
</html>